package org.rich.charlesmurphy.ui;


import static org.rich.charlesmurphy.core.CMIds.START_TIME;
import static org.rich.charlesmurphy.core.CMIds.TIME;

import java.awt.BorderLayout;

import javax.swing.JComponent;
import javax.swing.JPanel;

import org.windowkit.toolkit.widget.table.RecordTablePane;
import org.windowkit.toolkit.widget.table.TableSelectionType;
import org.windowkit.toolkit.widget.table.render.DateRenderer;

/**
 * @author Rich
 *
 */
public abstract class AbstractTableView extends AbstractCharliePanel {

	private static final long serialVersionUID = 9006012195068970713L;
	private RecordTablePane table;
	public AbstractTableView(String title) {
		super(title);
	}

	protected abstract String[] getColumnIds();

	/**
	 * @return the table
	 */
	protected RecordTablePane getTable() {
		return table;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected void initComponents() {
		table = new RecordTablePane(LabelFactory.makeDisplayDescriptor(getColumnIds()), "");
		table.setColumnCellRenderer(TIME, new DateRenderer(LabelFactory.getDateFormat()));
		table.setColumnCellRenderer(START_TIME, new DateRenderer(LabelFactory.getDateFormat()));
		table.setSelectionType(TableSelectionType.MULTIPLE_INTERVAL_SELECTION);

	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected JComponent createContents() {
		JPanel r = new JPanel(new BorderLayout());
		r.add(table, BorderLayout.CENTER);
		return r;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected void addListeners() {

	}

}
